package org.example.mall.admin.model.entity.manage;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.example.mall.admin.configuration.file.Url;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户信息
 * </p>
 *
 * @author hzq
 * @since 2021-12-29
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("account")
@ApiModel(value = "Account对象", description = "用户信息")
public class Account extends Model<Account> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "account_id", type = IdType.AUTO)
    private Integer accountId;

    @ApiModelProperty(value = "唯一id", hidden = true)
    @TableField("union_id")
    @JsonIgnore
    private String unionId;

    @NotBlank(message = "名称不能为空")
    @ApiModelProperty(value = "昵称")
    @TableField("nickname")
    private String nickname;

    @ApiModelProperty(value = "电话号码")
    @TableField("phone")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    @TableField("email")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private String email;

    @ApiModelProperty(value = "创建时间")
    @TableField("create_time")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "修改时间")
    @TableField("update_time")
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "是否删除（1是0否）", hidden = true)
    @TableField("del")
    @TableLogic
    @JsonIgnore
    private String del;

    @ApiModelProperty(value = "版本")
    @TableField("version")
    @Version
    private Integer version;

    @Url
    @ApiModelProperty(value = "头像")
    @TableField("avatar")
    private String avatar;

    @ApiModelProperty(value = "部门id")
    @TableField("dept_id")
    private Integer deptId;


    @Override
    protected Serializable pkVal() {
        return this.accountId;
    }

}
